Skip to content

feat(#407): HAProxy 설정 추가#408

Merged
Yoonchulchung merged 1 commit intodevfrom
feat/407-haproxy
Feb 23, 2026
Merged

feat(#407): HAProxy 설정 추가#408
Yoonchulchung merged 1 commit intodevfrom
feat/407-haproxy

Conversation

@Yoonchulchung
Copy link
Member

Summary

데모 데이 전에 발생했던 보안 문제를 대응하고자 서버에만 적용했던 보안설정 파일을 dev 브랜치에 올릴려고 합니다.

Cloudflare를 적용했음에도, 무차별적으로 SSH 포트가 건드리거나, 443 및 80 포트로 비정상적인 접근 요청을 하는 공격들이 존재했습니다. HAProxy에 적용했던 보안 설정을 공유하고자 합니다.

Changes

  • Fail2ban 적용
  • iptable 관리
  • ip 블랙리스트 관리

Type of Change

  • Bug fix (기존 기능에 영향을 주지 않는 버그 수정)
  • New feature (기존 기능에 영향을 주지 않는 새로운 기능 추가)
  • Breaking change (기존 기능에 영향을 주는 수정)
  • Refactoring (기능 변경 없는 코드 개선)
  • Documentation (문서 수정)
  • Chore (빌드, 설정 등 기타 변경)
  • Release (develop → main 배포)

Related Issues

#407

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @Yoonchulchung, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

이 PR은 데모 데이 이전에 발생했던 보안 문제에 대응하기 위해 HAProxy에 보안 설정을 추가하는 것을 목표로 합니다. Cloudflare 적용에도 불구하고 발생했던 비정상적인 접근 요청과 SSH 포트 스캐닝 공격에 대비하여, Fail2ban, iptables 관리, IP 블랙리스트 관리 등 다양한 보안 강화 조치가 HAProxy 구성에 통합되었습니다. 이는 서버의 전반적인 보안 수준을 향상시키고 잠재적인 위협으로부터 시스템을 보호하는 데 기여합니다.

Highlights

  • HAProxy 보안 설정 추가: Fail2ban, iptables 관리, IP 블랙리스트 관리 등 HAProxy에 다양한 보안 설정이 적용되었습니다.
  • README.md 업데이트: 프로젝트 설명, 기능, 개발자 역할 및 인프라 스택 정보가 최신화되었습니다.
Changelog
  • README.md
    • 핵심 기능 및 주요 기능 섹션에서 이모티콘과 일부 강조 표시가 제거되었습니다.
    • "데이터 기반 분석 + 협업 프로세스 통합 관리" 문구가 "태그 기반 매칭 + 채팅 기반 협업 진행"으로 변경되었습니다.
    • "매칭 검사" 설명이 "매칭 알고리즘 기반 브랜드 추천"에서 "매칭 알고리즘 기반 브랜드 및 캠페인 추천"으로 업데이트되었습니다.
    • "Detailed Responsibilities" 섹션의 HTML/CSS 스타일링이 제거되었습니다.
    • "정윤철" 개발자의 역할에 "코드 컨벤션 관리" 및 "HAProxy를 이용한 서버 보안 관리"가 추가되었습니다.
    • "Project Structure" 섹션이 완전히 제거되었습니다.
    • "Infra" 섹션에서 "AWS EC2"와 "AWS RDS"가 "Gabia Cloud"로 대체되었고, "HAProxy"가 추가되었습니다.
  • haproxy/fail2ban-haproxy.conf
    • HAProxy 로그에서 403, 429 응답 및 취약점 스캔 패턴을 감지하기 위한 Fail2ban 필터 정의가 추가되었습니다.
  • haproxy/haproxy-log.service
    • HAProxy Docker 컨테이너의 로그를 파일로 스트리밍하는 systemd 서비스 유닛이 추가되었습니다.
  • haproxy/haproxy.cfg
    • HAProxy 전역 설정에 tune.h2.max-concurrent-streams 설정이 추가되어 서버 정보가 숨겨졌습니다.
    • defaults 섹션에 option forwardfor가 추가되었고, 기본 에러 페이지에서 HAProxy 버전 숨김 처리를 위한 errorfile 403 설정이 추가되었습니다.
    • http_in 및 https_in 프론트엔드에 IP 블랙리스트 (blacklist.lst) 기반 접근 거부, HTTP 요청률 제한 (Rate Limit), 유효 호스트 검증 (api.realmatch.co.kr) 로직이 추가되었습니다.
    • https_in 프론트엔드에 TLSv1.2 최소 버전 및 특정 암호화 스위트가 적용되었고, 다양한 보안 HTTP 응답 헤더(Strict-Transport-Security, X-Frame-Options 등)가 추가되었습니다.
    • Server 및 X-Powered-By 헤더가 응답에서 제거되었습니다.
    • content-length 헤더가 1보다 큰 경우 요청을 거부하는 로직이 추가되었습니다.
    • HAProxy 통계 페이지 (/stats)를 위한 listen stats 섹션과 Prometheus 메트릭 노출을 위한 frontend prometheus 섹션이 추가되었습니다.
  • haproxy/iptables-docker.conf
    • Fail2ban이 Docker 환경에서 DOCKER-USER iptables 체인을 사용하여 IP를 차단하고 해제하는 사용자 정의 액션이 추가되었습니다.
  • haproxy/jail-haproxy.conf
    • HAProxy 공격을 감지하고 iptables-docker 액션을 사용하여 IP를 차단하는 Fail2ban jail 설정이 추가되었습니다.
  • haproxy/logrotate-haproxy
    • HAProxy 접근 로그 파일 (/var/log/haproxy/access.log)에 대한 logrotate 설정이 추가되었습니다.
Activity
  • 현재까지 이 PR에 대한 인간 활동(댓글, 리뷰 등)은 없습니다.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@Yoonchulchung Yoonchulchung merged commit c8e01ae into dev Feb 23, 2026
1 check passed
@Yoonchulchung Yoonchulchung deleted the feat/407-haproxy branch February 23, 2026 10:11
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This PR introduces important security settings to HAProxy, including Fail2ban, rate limiting, and various security headers, which are good changes to address the mentioned security issues. However, a high-severity issue was identified: hardcoded credentials for the HAProxy statistics page. This should be remediated by using environment variables. Overall, the changes are positive, but ensure the hardcoded credentials are addressed for improved security.

stats refresh 5s
stats show-legends
stats show-node
stats auth admin:realmatch2026!
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security-high high

The HAProxy statistics page is configured with a hardcoded username and password (admin:realmatch2026!). Hardcoding credentials in configuration files committed to version control is a major security risk, exposing them to anyone with repository access. This could allow an attacker to monitor backend server health, view traffic, and potentially disable/enable servers, leading to denial of service. Additionally, line 71 (stats admin if TRUE) grants administrative privileges to any authenticated user. It is critical to replace these hardcoded credentials with environment variables or other secure injection methods.

    stats auth ${STATS_USER}:${STATS_PASSWORD}

@@ -0,0 +1,8 @@
[haproxy-attack]
enabled = true
filter = haproxy-attack
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

fail2ban jail 설정에서 filterhaproxy-attack으로 지정했습니다. fail2ban이 이 필터를 찾으려면, 필터 정의 파일의 이름이 haproxy-attack.conf (또는 .local)이어야 합니다. 하지만 이 PR에서 추가된 필터 파일의 이름은 fail2ban-haproxy.conf입니다. 이 이름 불일치로 인해 해당 jail이 정상적으로 동작하지 않을 것입니다. fail2ban-haproxy.conf 파일의 이름을 haproxy-attack.conf로 변경하여 filter 설정과 일치시켜야 합니다.

단순 매칭을 넘어,

> 👉 **데이터 기반 분석 + 협업 프로세스 통합 관리**
> **태그 기반 매칭 + 채팅 기반 협엽 진행**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

'협엽'은 '협업'의 오타로 보입니다. 수정하는 것이 좋겠습니다.

Suggested change
> **태그 기반 매칭 + 채팅 기반 협엽 진행**
> **태그 기반 매칭 + 채팅 기반 협업 진행**

Comment on lines +10 to +12
failregex = ^\s*<HOST>:\d+\s+\[.*\]\s+\S+\s+\S+\s+\S+\s+403\s
^\s*<HOST>:\d+\s+\[.*\]\s+\S+\s+\S+\s+\S+\s+429\s
^\s*<HOST>:\d+\s+\[.*\]\s+\S+\s+\S+\s+\S+\s+\d+\s.*"(GET|POST|PUT|DELETE|HEAD|OPTIONS)\s+.*(\.php|cgi-bin|\.env|wp-admin|wp-login|\.git|shell|passwd|\.asp)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

현재 취약점 스캔을 위한 정규식이 너무 광범위하여 정상적인 요청을 차단할 오탐(false positive)의 가능성이 있습니다. 예를 들어, URL 파라미터에 .git과 같은 문자열이 포함된 경우에도 차단될 수 있습니다. 요청 경로(path)에 대해서만 패턴을 검사하고, 요청 문자열의 끝을 명확히 하는 등 정규식을 좀 더 정교하게 수정하여 오탐을 줄이는 것을 권장합니다.

failregex = ^\s*<HOST>:\d+\s+\[.*\]\s+\S+\s+\S+\s+\S+\s+403\s
            ^\s*<HOST>:\d+\s+\[.*\]\s+\S+\s+\S+\s+\S+\s+429\s
            ^\s*<HOST>:\d+\s+\[.*\]\s+\S+\s+\S+\s+\S+\s+\d+\s.*"(?:GET|POST|PUT|DELETE|HEAD|OPTIONS)\s+[^\"]*?(\.php|/cgi-bin|/\.env|/wp-admin|/wp-login|/\.git|/shell|/passwd|/\.asp)[^\"]*"

http-response set-header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"
http-response set-header X-Frame-Options "SAMEORIGIN"
http-response set-header X-Content-Type-Options "nosniff"
http-response set-header X-XSS-Protection "1; mode=block"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

X-XSS-Protection 헤더는 현재 대부분의 모던 브라우저에서 지원이 중단되었으며, 오히려 특정 상황에서 보안 취약점을 유발할 수 있어 사용이 권장되지 않습니다. 더 강력하고 표준적인 XSS 방어는 Content-Security-Policy 헤더를 통해 구현할 수 있습니다. 우선 이 헤더를 제거하는 것을 권장합니다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant